
var vm = avalon.define({
    $id: "vm-create",
    form_data: {
        promoter_name: $("input[name='hidden_promoter_name']").val() || '',
		password: '',
        is_effect: $("input[name='hidden_is_effect']").val() || 1,
        id: $objAction.getQueryString("id") || null
    },
    bm_three: $("input[name='hidden_bm_three']").val() || '鱼商',
    bindMobileID: '',
    bindMobileNickName: '',
    check(){
        // 表单验证
        if($checkAction.checkEmpty(this.form_data.promoter_name)){
            layer.msg(`请输入${this.bm_three}名称`);
            return false;
        }
        else if($checkAction.checkEmpty(this.form_data.password)){
            layer.msg('请输入密码');
            return false;
        }
        else{
            return true;
        }
    },
    submit() {
        // 提交创建
        if(this.check()){
            layer.load();
            $handleAjax.handle({
                url: APP_ROOT + "/mapi/index.php?ctl=user_two&act=three_update",
                isTip: false,
                data: this.form_data
            }).done(function(result){
                layer.closeAll();
                if(result.status == 1){
                    layer.msg(result.error || '操作成功',{
                        time: 1000
                    });
                    setTimeout(function(){
                        location.href = TMPL_REAL + "/index.php?ctl=user_two&act=three_index";
                    }, 1000);
                }
                else{
                    layer.msg(result.error || '操作失败');
                }

            }).fail(function(err){
                console.log(err);
            });
        }
    }
});